<template>
  <j-modal
    :visible.sync='visible'
    :width='1200'
    :title='title'
  >
    <template>
      <div>
      <a-table
        id="datatable"
        ref='table'
        size='middle'
        :scroll='{x:true}'
        bordered
        rowKey='id'
        :columns='columns'
        :dataSource='dataSourceModal'
        :pagination='ipagination'
        :loading='loading'
        class='j-table-force-nowrap'
        @change='handleTableChange'>

        <template slot='htmlSlot' slot-scope='text'>
          <div v-html='text'></div>
        </template>
        <template slot='imgSlot' slot-scope='text'>
          <span v-if='!text' style='font-size: 12px;font-style: italic;'>无图片</span>
          <img v-else :src='getImgView(text)' height='25px' alt=''
               style='max-width:80px;font-size: 12px;font-style: italic;' />
        </template>
        <template slot='fileSlot' slot-scope='text'>
          <span v-if='!text' style='font-size: 12px;font-style: italic;'>无文件</span>
          <a-button
            v-else
            :ghost='true'
            type='primary'
            icon='download'
            size='small'
            @click='downloadFile(text)'>
            下载
          </a-button>
        </template>

        <span slot='action' slot-scope='text, record'>
           <a @click='handleSelect(record)'>选择</a>
        </span>

      </a-table>
      </div>
    </template>
    <template slot='footer'>
      <a-button @click='closeMessage'>关闭</a-button>
    </template>
  </j-modal>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import { postAction } from '@api/manage'

export default {
  name: 'CouClassListModal',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
  },
  props: {
    dataSourceModal: {
      type: Array,
      default: []
    },
    title: {
      type: String,
      default: '选择班级'
    }
  },
  data() {
    return {
      description: 'cou_class管理页面',
      // 表头
      columns: [
        {
          title: '班级编码',
          align: 'center',
          dataIndex: 'classCode'
        },
        {
          title: '班级名称',
          align: 'center',
          dataIndex: 'className'
        },
        {
          title: '班级简称',
          align: 'center',
          dataIndex: 'classNickname'
        },
        {
          title: '班级类型',
          align: 'center',
          dataIndex: 'classTtype_dictText'
        },
        {
          title: '班级容量',
          align: 'center',
          dataIndex: 'classStudentCapacity'
        },
        {
          title: '届级',
          align: 'center',
          dataIndex: 'classGradesessionYear'
        },
        {
          title: '班级状态',
          align: 'center',
          dataIndex: 'classStatus_dictText'
        },
        {
          title: '班主任(教师编码)',
          align: 'center',
          dataIndex: 'classHeadmasterCode_dictText'
        },
        {
          title: '班级人数',
          align: 'center',
          dataIndex: 'classStudentCount'
        },
        {
          title: '是否启用',
          align: 'center',
          dataIndex: 'classIzOpen_dictText'
        },
        {
          title: '班级排序',
          align: 'center',
          dataIndex: 'classOrder'
        },
        {
          title: '班级备注',
          align: 'center',
          dataIndex: 'classRemark'
        },
        {
          title: '年级',
          align: 'center',
          dataIndex: 'gradeCode_dictText'
        },
        {
          title: '虚拟账号',
          align: 'center',
          dataIndex: 'userId_dictText'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      visible: false

    }
  },
  created() {
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    loadData() {

    },
    openModal() {
      if (this.visible === false) {
        this.visible = true
      }
    },
    closeMessage() {
      if (this.visible === true) {
        this.visible = false
      }
      this.$bus.$emit('closeCouClassListModal', {})
    },
    handleSelect(val) {
      if (this.visible === true) {
        this.visible = false
      }
      this.$bus.$emit('closeCouClassListModal', val)
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>